package net.xju.dao;

import net.xju.common.utils.JdbcUtilsV1;
import net.xju.entity.Admin;

import java.util.List;

public class AdminDao {
    public Admin login(String username, String password) {
        String sql = "SELECT id, username, password, age, gender FROM Admins WHERE username = ? AND password = ?";
        return JdbcUtilsV1.executeQueryOne(JdbcUtilsV1.getConnection(), Admin.class, sql, username, password);
    }

    public boolean update(Admin admin) {
        String sql = "UPDATE Admins SET password = ?, age = ?, gender = ? WHERE id = ?";
        int i = JdbcUtilsV1.executeUpdate(sql, admin.getPassword(), admin.getAge(), admin.getGender(), admin.getId());
        return i > 0;
    }
}